import React,{useState} from 'react'
import{useNavigate} from 'react-router-dom'
import { Uploader } from 'react-vant'

import '../css/Add.css'
import axios from 'axios'
axios.defaults.baseURL = 'http://localhost:3000/'

const defaultValue = [

]



export default function Community_add() {
    const navigator = useNavigate()
    const [username, setText] =useState('')
    return (
        <div>
            <div className='add'>
                <div className='add_1'>
                    <div className='add_img'>
                        <img src="/fan.png" alt="" onClick={()=>{navigator('/home/community/jing')}}/>
                    </div>
                    <div className='add_2'>
                        <h2>发布到社区</h2>
                    </div>
                </div>
                <div className='add_2'>
                    <div className='add_textarea'>
                        <textarea name="" value={username} onChange={(e)=>{setText(e.target.value)}} placeholder='编辑你得动态...' id="" cols="" rows=""></textarea>
           
                    </div>

                </div>
                <div className='add_upload'>
                
                    <Uploader 
                    className='add_upload_img'
                        accept='*'
                        defaultValue={defaultValue}
                        onChange={v => console.log(v)}
                    />
                </div>
                <div className='add_input1'>
                    <span>添加标签 +</span>
          
                    <img src="/add1.png" alt="" />
                </div>
                <div className='add_input2'>
                    <span>添加车型 +</span>
                    <img src="/add2.png" alt="" />
                </div>
                <div className='add_input3'>
                    <span>添加位置 +</span>
                    <img src="/add3.png" alt="" />
                </div>
                <div className='add_input4'>
                    <span onClick={async()=>{
                        await axios.post('Useradd',{username:username})
                        setText('')
                    }}>
                        <img src="/add4.png" alt="" />
                    </span>
                </div>
            </div>
        </div>
    )
}
